package com.itheima.text1;

public class Student implements Comparable<Student> {
    private String name;
    private int age;
    private int score;

    public Student() {
    }

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }


    @Override
    public int compareTo(Student o) {
        //首要条件 按成绩排序
        int num1 = this.score - o.score;
        //次要条件 成绩相同按年龄排序
        int num2 = num1 == 0 ? this.age - o.age : num1;
        //最后条件 ----- 按首字母排序
       int num3 = num2 == 0 ? this.name.compareTo(o.name) : num2;
        return num3;
    }
}
